/**
 * 门店信息页面
 * author:zhangjlt
 * date:2017年3月13日13:30:42
 */
;
define(function(require, exports, module) {
	var wechat = require("wechat");
	var template = require("template");
	template.helper('formatPoint', function(point) {
		if(point) {
			var point = Number(point);
			if(point != NaN) {
				return point;
			} else {
				return 0;
			}
		} else {
			return 0;
		}
	});
	var shopByCar = {
		data: {},
		/**
		 * bindEvent 页面事件
		 */
		bindEvent: function() {
			//返回
			$("#return_shopByCar").unbind().on("click", function() {
				window.location.href = "#home";
			});
		},
		/**
		 * 进行页面路由监听配置
		 * 
		 */
		bindRout: function() {
			//公共页面监听路由
			Path.map("#home").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: false,
					from: "left"
				});
			});
			Path.listen();
		},
		/**
		 * 页面数据加载
		 */
		initData: function() {
			//iscroll滚动加入
			var iscroll = require("iscroll");
			common.initIscroll({
				container: "iscrollContent_shopByCar",
				showScrollBar: false,

			});

			var _this = this;
			//			var param = {};
			//			common.loadData({
			//				url: "/getshopByCarListt",
			//				param: param,
			//				successCallBack: _this.getshopByCarListCallBack, //回调函数
			//				dataSource: "getshopByCarList"
			//			});

		},
		//callback function
		getshopByCarListCallBack: function(json) {
			console.log("调用后台ajax返回值为：" + JSON.stringify(json));
			if(json.status == "0") {
				shopByCar.data = json;
				var html2 = template('shopByCarTemplate', shopByCar.data);
				document.getElementById('main_shopByCar').innerHTML = html2;
			} else {
				common.showTip({
					content: json.message
				});
			}

		},
		/**
		 * each page init mothed
		 */
		initialize: function() {
			//动态加载数据
			this.initData();
			//事件绑定
			this.bindEvent();
			//路由绑定
			this.bindRout();
		}
	};

	module.exports = shopByCar;
});